home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / hsc / source / ugly / dllist.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-02  |  2.9 KB  |  103 lines

  1. /*
  2.  * This source code is part of hsc, a html-preprocessor,
  3.  * Copyright (C) 1993-1997  Thomas Aglassinger
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20. #ifndef UGLY_DLLIST_H
  21. #define UGLY_DLLIST_H           /* avoid include twice */
  22.  
  23. /*
  24.  * dllist.h
  25.  *
  26.  * doubel linked list functions, header
  27.  *
  28.  * (W) by Tommy-Saftwörx in 1994,95
  29.  *
  30.  */
  31.  
  32. #include <stdio.h>
  33.  
  34. #include "utypes.h"
  35.  
  36. /*
  37.  *
  38.  * double linked list structs
  39.  *
  40.  */
  41. struct dlnode
  42. {
  43.     struct dlnode *prev;        /* previous entry */
  44.     struct dlnode *next;        /* next entry */
  45.     APTR data;                  /* ptr to data */
  46. };
  47.  
  48. struct dllist
  49. {
  50.     /* PRIVATE (read-only) */
  51.     struct dlnode *first;       /*   first entry */
  52.     struct dlnode *last;        /*   last entry */
  53.     LONG entry_num;             /*   num of entris in list */
  54.     void (*del_data) (APTR data);       /*   func that removes data */
  55.     /* PUBLIC */
  56.     APTR user_data;             /*   user data */
  57. };
  58.  
  59. typedef struct dllist DLLIST;
  60. typedef struct dlnode DLNODE;
  61.  
  62. /*
  63.  * access methodes
  64.  */
  65. #define dll_first( list ) ((list)->first)
  66. #define dll_last( list )  ((list)->last)
  67. #define dln_prev( node )  ((node)->prev)
  68. #define dln_next( node )  ((node)->next)
  69. #define dln_data( node )  ((node)->data)
  70.  
  71. /*
  72.  *
  73.  * external functions prototypes
  74.  *
  75.  */
  76. #ifndef NOEXTERN_UGLY_DLLIST_H
  77.  
  78. extern DLLIST *init_dllist(void (*del_data) (APTR data));
  79. extern DLNODE *new_dlnode(void);
  80. extern DLNODE *ins_dlnode(DLLIST * list, DLNODE * node, APTR data);
  81. extern DLNODE *app_dlnode(DLLIST * list, APTR data);
  82. extern DLNODE *add_dlnode(DLLIST * list, APTR data);
  83.  
  84. extern APTR detach_dlnode(DLLIST * list, DLNODE * node);
  85. extern void del_dlnode(DLLIST * list, DLNODE * node);
  86. extern VOID del_all_dlnodes(DLLIST * list);
  87. extern void del_dllist(DLLIST * list);
  88.  
  89. extern BOOL empty_dllist(DLLIST * list);
  90.  
  91. extern void fprintf_dllist(FILE * stream, DLLIST * list,
  92.                            void (*fprintf_data) (FILE * stream, APTR data));
  93. extern void do_dllist(DLLIST * list, void (*func) (APTR data));
  94.  
  95. extern DLNODE *find_dlnode(DLNODE * start, APTR data,
  96.                            int (*compare) (APTR cmp_data, APTR list_data));
  97. extern DLNODE *find_dlnode_bw(DLNODE * start, APTR data,
  98.                             int (*compare) (APTR cmp_data, APTR list_data));
  99.  
  100. #endif /* NOEXTERN_UGLY_DLLIST_H */
  101.  
  102. #endif /* UGLY_DLLIST_H */
  103.